/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package org.jasoet.swing.cellrenderer;

import java.awt.Component;
import java.text.SimpleDateFormat;
import javax.swing.JLabel;
import javax.swing.JTable;
import javax.swing.SwingConstants;
import javax.swing.table.DefaultTableCellRenderer;

/**
 *
 * @author Deny Prasetyo
 */
public class DateTableCellRenderer extends DefaultTableCellRenderer {

    private SimpleDateFormat simpleDateFormat = new SimpleDateFormat("dd MMMM yyyy");

    @Override
    public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) {
        JLabel component = (JLabel) super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column);
        component.setHorizontalAlignment(SwingConstants.CENTER);
        component.setText(simpleDateFormat.format(value));

        return component;
    }
}
